<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 * @author   howe <howe1995@163.com>
 */

namespace App\Jobs;

use App\Services\AssistantService;
use GuzzleHttp\Exception\GuzzleException;
use Hyperf\AsyncQueue\Job;

class AssistantReplyJob extends Job
{
    public $queue = 'chat_assistant_reply';

    // 设置最大重试次数
    public int $tries = 3;

    // 设置失败后等待的秒数
    public int $backoff = 10;

    protected array $data;

    /**
     * Create a new job instance.
     *
     * @param mixed $data
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Execute the job.
     *
     * @throws GuzzleException
     */
    public function handle(): void
    {
        $assistantService = new AssistantService();
        $assistantService->replyMessage($this->data);
    }
}
